package com.bingxue.edu.management.system.model.req;

import com.bingxue.edu.common.enums.CommonStatusEnum;
import com.bingxue.edu.common.enums.StorageTypeEnum;
import com.bingxue.edu.framework.common.validation.Code;
import com.bingxue.edu.framework.common.validation.Name;
import com.bingxue.edu.management.system.util.ValidateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

/**
 * 创建或修改存储配置信息
 *
 * @author panbo
 * @since 2024/07/22 23:33
 */
@Data
@Schema(description = "创建或修改存储配置信息")
public class StorageReq {

    @Schema(description = "名称")
    @Name
    @NotBlank(message = "名称不能为空")
    private String name;

    @Schema(description = "编码")
    @Code
    @NotBlank(message = "编码不能为空")
    private String code;

    @Schema(description = "类型")
    @NotNull(message = "类型不能为空")
    private StorageTypeEnum type;

    @Schema(description = "访问密钥")
    @Length(max = 255, message = "访问密钥长度不能超过 {max} 个字符")
    @NotBlank(message = "访问密钥不能为空", groups = ValidateGroup.Storage.S3.class)
    private String accessKey;

    @Schema(description = "私有密钥")
    @Length(max = 255, message = "私有密钥长度不能超过 {max} 个字符")
    @NotBlank(message = "私有密钥不能为空", groups = ValidateGroup.Storage.S3.class)
    private String secretKey;

    @Schema(description = "终端节点")
    @Length(max = 255, message = "终端节点长度不能超过 {max} 个字符")
    @NotBlank(message = "终端节点不能为空", groups = ValidateGroup.Storage.S3.class)
    private String endpoint;

    @Schema(description = "桶名称")
    @Length(max = 255, message = "桶名称长度不能超过 {max} 个字符")
    @NotBlank(message = "桶名称不能为空", groups = ValidateGroup.Storage.S3.class)
    @NotBlank(message = "存储路径不能为空", groups = ValidateGroup.Storage.Local.class)
    private String bucketName;

    @Schema(description = "域名")
    @NotBlank(message = "域名不能为空")
    @Length(max = 255, message = "域名长度不能超过 {max} 个字符")
    private String domain;

    @Schema(description = "描述")
    @Length(max = 255, message = "描述长度不能超过 {max} 个字符")
    private String description;

    @Schema(description = "是否为默认存储")
    @NotNull(message = "是否为默认存储不能为空")
    private Boolean defaultStorage;

    @Schema(description = "状态")
    @NotNull(message = "状态不能为空")
    private CommonStatusEnum status;

    @Schema(description = "排序", example = "1")
    private Integer sort;
}
